<%@page import="java.sql.ResultSet"%>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<% response.setContentType("text/html; charset=UTF-8");%>
<% request.setCharacterEncoding("utf-8");%>
<%@page import="controller.ModuleExamController, dto.*" %>
<%@page import="java.sql.ResultSet" %>

<%
    String maLDT = request.getParameter("maldt");
    ModuleExamController ctrl = new ModuleExamController();
    if (maLDT != null) {
        HttpSession ss = request.getSession();
        if (ss.getAttribute("maTS") != null) {
            String maTS = ss.getAttribute("maTS").toString();
            ResultSet rs = ctrl.getDeThi(Integer.parseInt(maLDT));

            while (rs.next()) {
                out.println("<div class='item " + Integer.toString(rs.getInt("maDT"))
                        + "' onclick=\" dethi_select('" + Integer.toString(rs.getInt("maDT")) + "'); \" >");

                out.println("<div class='header'>Mã đề thi : <b>");
                out.println(Integer.toString(rs.getInt("maDT")));
                out.println("</b></div>");

                out.println("<div class='info'>Số lượng câu hỏi : <b>");
                out.println(Integer.toString(rs.getInt("SoCH")));
                out.println("</b></div>");

                int soLuong = ctrl.getSoLuongBaiThi(rs.getInt("maDT"), maTS);
                if (soLuong > 0) {
                    out.println("<div class='info'><b>Đã từng thi</b></div>");
                } else {
                    out.println("<div class='info'><i>Chưa thi</i></div>");
                }

                out.println("</div>");
            }
            rs.close();
        }
    }
%>